﻿using StaffingSystem.Business;
using StaffingSystem.EF;
using StaffingSystem.Models;
using StaffingSystem.Tool;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace StaffingSystem.Controllers
{
    public class OfficialController : Controller
    {

        #region 转正列表
        // GET: Official
        JsonResult result;
        public ActionResult OfficialEmp()
        {
            return View();
        }

        [HttpPost]
        public ActionResult OfficialEmp(PageViewModel page)
        {
            result = new JsonResult();
            Personnelinfor list = new Personnelinfor();
            PageModel<Official_USE> pagemodel = new PageModel<Official_USE>();
            pagemodel.PageSize = page.PageSize;
            pagemodel.PageNumber = page.PageNumber;
            pagemodel.TableName = "Official_USE";
            pagemodel.PageKey = "JobNumber";
            if (page.D_NameR != null)
            {
                pagemodel.Where = " D_Name='" + page.D_NameR + "' and days>90";
            }
            else
            {
                pagemodel.Where = " days>90";
            }


            pagemodel.OrderID = "JobNumber";
            pagemodel.AscOrDesc = string.Empty;
            pagemodel = list.GetPageList(pagemodel);

            result.Data = new
            {
                Sate = 0,
                Message = "获取数据成功",
                Data = JsonTool.JsonSerializer(pagemodel)
            };
            return result;
        }
        #endregion


        #region 转正审批
        [HttpPost]
        public ActionResult Emp(string id)
        {
            result = new JsonResult();
            Management db = new Management();
            Personnelinfor list = new Personnelinfor();

            string proc = "Official_true";


            if (list.Official(proc, id) > 0)
            {
                result = DataHelper.GetResult(ExecuteState.Succeed, "转正操作成功！", "");
            }
            else
            {
                result = DataHelper.GetResult(ExecuteState.Failed, "转正操作失败！", "");
            }
            return result;
        }
        [HttpPost]
        public ActionResult Emps(string id)
        {
            result = new JsonResult();
            Management db = new Management();
            Personnelinfor list = new Personnelinfor();

            string proc = "Official_false";


            if (list.Official(proc, id) > 0)
            {
                result = DataHelper.GetResult(ExecuteState.Succeed, "已审阅！", "");
            }
            else
            {
                result = DataHelper.GetResult(ExecuteState.Failed, "审阅失败！", "");
            }
            return result;
        }
        #endregion
        
      
    }
}